<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\LinkMan;

class Agent extends Model
{
	const STATE_OFFSHELF = 0;
	const STATE_NORMAL = 1;
	const STATE_ALL = 3;
	const STATE_OFFSHELF_STRING = '禁用';
	const STATE_NORMAL_STRING = '启用';
	const STATE_ALL_STRING = '全部';

	const TYPE_AGENT = 1; 
	const TYPE_DIRECT = 2;
	const TYPE_ORDINARY =3;
	const TYPE_AGENT_STRING = '代理商';
	const TYPE_DIRECT_STRING = '直营';
	const TYPE_ORDINARY_STRING = '普通';
	
	
    protected $table = 'at_enterprise_info';
    protected $primaryKey = 'id';

    public function linkman()
    {
    	return $this->hasOne(LinkMan::class,'id');//,'at_enterprise_info_id');
    }
    
    public function sysuser(){
    	return $this->hasOne(SysUser::class,'id');
    }

    
    public static function getStateDispayMap()
    {
    	return [
    			//self::STATE_ALL =>self::STATE_ALL_STRING,
    			self::STATE_OFFSHELF => self::STATE_OFFSHELF_STRING,
    			self::STATE_NORMAL => self::STATE_NORMAL_STRING,
    	];
    }
    
    public static function getTypeDispayMap(){
    	return [
    			self::TYPE_AGENT =>self::TYPE_AGENT_STRING,
    			self::TYPE_DIRECT =>self::TYPE_DIRECT_STRING,
    			self::TYPE_ORDINARY =>self::TYPE_ORDINARY_STRING,
    	];
    }
}
